package com.neusoft.springdemo.controller;

import java.util.List;

import com.neusoft.springdemo.bean.Food;
import com.neusoft.springdemo.serviice.FoodService;

/**
 * 
 * @author chens
 *
 */
public class FoodController {

	private FoodService foodService;

	/**
	 * set方法注入
	 * 
	 * @param foodService
	 */
	public void setFoodService(FoodService foodService) {
		this.foodService = foodService;
		System.out.println("=========  setFoodService(FoodService foodService)  ==============");
	}

	public FoodController() {
		super();
		System.out.println("=========  FoodController()  ==============");
	}

	/**
	 * 构造方法注入
	 * 
	 * @param foodService
	 */
	public FoodController(FoodService foodService) {
		super();
		this.foodService = foodService;

		System.out.println("=========  FoodController(FoodService foodService)  ==============");
	}

	/**
	 * 查询产品信息
	 * 
	 * @return
	 */
	public List<Food> listFoodList() {
		return foodService.getList();
	}

	public boolean addFood() {

		Food food = new Food(1000, "鱼香肉丝", "微辣，口感很好", 23.1, 1);

		return foodService.add(food);
	}

	public boolean editFood() {

		Food food = new Food(1000, "鱼香肉丝", "微辣，口感很好", 23.1, 1);

		return foodService.edit(food);
	}

	public boolean deleteFood() {

		Food food = new Food(1000, "鱼香肉丝", "微辣，口感很好", 23.1, 1);

		return foodService.delete(food);
	}
}
